package com.ms3ds.deviceData.api.factory;

import com.ms3ds.common.core.domain.R;
import com.ms3ds.deviceData.api.RemoteMiningRecordService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 矿山信息服务降级处理
 * 
 * @author ruoyi
 */
@Component
public class RemoteMiningRecordFallbackFactory implements FallbackFactory<RemoteMiningRecordService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteMiningRecordFallbackFactory.class);

    @Override
    public RemoteMiningRecordService create(Throwable throwable)
    {
        log.error("设备数据服务调用失败:{}", throwable.getMessage());
        return new RemoteMiningRecordService()
        {
            @Override
            public R<Boolean> generateMiningRecord() {
                return R.fail("模拟生成矿石开采记录失败:" + throwable.getMessage());
            }


        };
    }
}
